# encoding=utf-8

"""DirMakeFactory.py
    - 临时目录有很多，因此采用工厂设计模式
"""
import os
import traceback

import flask


class DirMakeFactory:
    def base_parser(self, **kwargs):
        save_dir = kwargs.get('save_dir', None)
        user_name = kwargs.get('user_name', None)
        token = kwargs.get('token', None)
        return save_dir, user_name, token

    @staticmethod
    def remove_file(file_name: str):
        if os.path.exists(file_name):
            try:
                os.remove(file_name)
            except:
                print(traceback.format_exc())

    def path_init_with_request(self, request: flask.Request, save_dir: str = None):
        raise NotImplementedError

    def path_init(self, **kwargs):
        raise NotImplementedError

    def temp_dir_create(self, **kwargs):
        raise NotImplementedError
